package MementoPattern.demo;

/**
 * @author： pang-yun
 * @date： 2022-01-05 20:34
 * 功能目的 ：用于
 */

public class Client {
    public static void main(String[] args) {
        Originator originator = new Originator();
        Caretaker caretaker = new Caretaker();

        caretaker.add(originator.saveStateMemento());

        originator.setState("状态2: restore");
        caretaker.add(originator.saveStateMemento());

        originator.setState("状态3: fire");
        caretaker.add(originator.saveStateMemento());

        originator.getStateFromMemento(caretaker.getById(1));
        System.out.println(originator.getState());

    }
}
